Skip to content

RDKEMW-17873: HDMI-CEC Polaris HAL Migration - #57

Merged
anand-ky merged 10 commits into
support/AIDLfrom
feature/factoryImpl
Jun 29, 2026
Merged

RDKEMW-17873: HDMI-CEC Polaris HAL Migration#57
anand-ky merged 10 commits into
support/AIDLfrom
feature/factoryImpl

Conversation

@IshvarKR

@IshvarKR IshvarKR commented Jun 2, 2026

Copy link
Copy Markdown

No description provided.

Comment thread ccec/src/factoryImpl/HDMICecHalFactory.h Outdated
Comment thread ccec/src/factoryImpl/HDMICecHalFactory.cpp Outdated

@apatel859 apatel859 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cimpile this code in normal build and vdevice build and see if you face any compilation issue?

@Sid2001-maker
Sid2001-maker force-pushed the feature/factoryImpl branch 2 times, most recently from 876022c to 1c009ec Compare June 3, 2026 09:34
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@IshvarKR
IshvarKR force-pushed the feature/factoryImpl branch from 02757ea to ba51587 Compare June 9, 2026 10:51
@vinodtel
vinodtel marked this pull request as ready for review June 9, 2026 16:55
@vinodtel
vinodtel requested a review from a team as a code owner June 9, 2026 16:55
Copilot AI review requested due to automatic review settings June 9, 2026 16:55
@vinodtel vinodtel changed the title Feature/factory impl VDevice : HDMI-CEC Middleware component Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a HAL abstraction + factory to switch the CCEC driver between a legacy C HAL backend (vHAL) and an Android Binder/AIDL backend (AidlHAL), and updates the build to produce/link the new backend libraries.

Changes:

  • Added HDMICecHal interface and HDMICecHalFactory to select AIDL vs legacy backend at runtime.
  • Implemented vHAL (legacy C driver wrapper) and AidlHAL (binder/AIDL implementation).
  • Updated DriverImpl to route all HAL operations through the new interface; updated Makefiles to build/link backend shared libraries.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
ccec/src/Makefile.am Builds libvHAL.la + libAidlHAL.la and links them into libRCEC.la.
ccec/src/Makefile Builds libvHAL.so + libAidlHAL.so and links them into libRCEC.so; adds binder/AIDL include/link plumbing.
ccec/src/factoryImpl/HDMICecHal.h New abstract HAL interface used by DriverImpl.
ccec/src/factoryImpl/HDMICecHalFactory.h Declares factory for backend selection.
ccec/src/factoryImpl/HDMICecHalFactory.cpp Implements backend selection via binder service discovery.
ccec/src/factoryImpl/vHAL.h Declares legacy backend wrapper.
ccec/src/factoryImpl/vHAL.cpp Implements legacy backend wrapper via HdmiCec* C APIs.
ccec/src/factoryImpl/AidlHAL.h Declares AIDL/binder backend.
ccec/src/factoryImpl/AidlHAL.cpp Implements AIDL/binder backend + poll ACK emulation + frame length filtering.
ccec/src/DriverImpl.hpp Stores std::unique_ptr<HDMICecHal> for the selected backend.
ccec/src/DriverImpl.cpp Uses HDMICecHal for open/close/read/write operations and AIDL-specific behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ccec/src/DriverImpl.cpp Outdated
Comment thread ccec/src/DriverImpl.cpp Outdated
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/AidlHAL.cpp Outdated
Comment thread ccec/src/Makefile
Comment thread ccec/src/factoryImpl/HDMICecHal.h Outdated
Comment thread ccec/src/factoryImpl/AidlHAL.cpp Outdated
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Copilot AI review requested due to automatic review settings June 11, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.

Comment thread ccec/src/factoryImpl/IHDMICecHal.h
Comment thread ccec/src/factoryImpl/HDMICecHalFactory.cpp Outdated
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/Makefile.am Outdated
Comment thread ccec/src/Makefile.am Outdated
Comment thread ccec/src/Makefile.am Outdated
Comment thread ccec/src/Makefile Outdated
Comment thread ccec/src/Makefile Outdated
Copilot AI review requested due to automatic review settings June 11, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/DriverImpl.cpp Outdated
Comment thread ccec/src/DriverImpl.cpp Outdated
Comment thread ccec/src/Makefile.am Outdated
Comment thread ccec/src/Makefile
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.h
Comment thread ccec/src/factoryImpl/HDMICecHalFactory.cpp
Copilot AI review requested due to automatic review settings June 15, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Comment thread ccec/src/factoryImpl/HDMICecHalFactory.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp Outdated
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp Outdated
Comment thread ccec/src/Makefile.am Outdated
Copilot AI review requested due to automatic review settings June 23, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Comment on lines +46 to +57
class HalFactoryUtility {
enum class BackendType {
UNKNOWN,
LEGACY,
AIDL
};

static BackendType mBackendType;

bool isAidlServiceAvailable(const android::String16 &expectedServiceName)
{
CCEC_LOG(LOG_INFO, "isAidlServiceAvailable invoked\r\n");
{
CCEC_LOG(LOG_INFO, "HDMICecHalFactory::Create invoked\r\n");

if (HalFactoryUtility::isAidlServiceAvailable(IHdmiCec::serviceName().c_str())) {
Comment on lines +239 to +242
const size_t binder_map_size = (version.protocol_version == 7) ? BINDER_MMAP_SIZE_V7 : BINDER_MMAP_SIZE_V8;
void* const mapped_mem = mmap(nullptr, binder_map_size, PROT_READ, MAP_PRIVATE, binder_fd, 0);
if (mapped_mem == MAP_FAILED) {
CCEC_LOG(LOG_ERROR, "[-] Shared address space context instantiation failed\n");
Comment thread ccec/src/factoryImpl/HDMICecRdkVHAL.cpp Outdated
Comment on lines +139 to +140
CCEC_LOG(LOG_DEBUG, "HDMICecRdkVHAL::getPhysicalAddress handle=%d ret=%d addr=0x%x\r\n",
ret, (physicalAddress ? *physicalAddress : 0));
Comment thread ccec/src/factoryImpl/HDMICecAidlHAL.cpp
Comment on lines +304 to +313
int HDMICecAidlHAL::getPhysicalAddress(int handle, unsigned int *physicalAddress)
{
if (physicalAddress != nullptr) {
*physicalAddress = 0;
}

CCEC_LOG( LOG_DEBUG, "HDMICecAidlHAL::getPhysicalAddress completed\r\n");

return 0;
}
Comment thread ccec/src/Makefile.am
Comment on lines +36 to 41
factoryImpl/HDMICecHalFactory.cpp \
factoryImpl/HDMICecRdkVHAL.cpp \
factoryImpl/HDMICecAidlHAL.cpp \
factoryImpl/ServiceManagerCheck.cpp

libRCEC_la_LDFLAGS = -lpthread
Copilot AI review requested due to automatic review settings June 23, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Comment thread ccec/src/Makefile.am
Comment on lines +36 to +39
factoryImpl/HDMICecHalFactory.cpp \
factoryImpl/HDMICecRdkVHAL.cpp \
factoryImpl/HDMICecAidlHAL.cpp \
factoryImpl/ServiceManagerCheck.cpp
CCEC_LOG(LOG_INFO, "[+] Binder protocol version detected: %d\n", version.protocol_version);

const size_t binder_map_size = (version.protocol_version == 7) ? BINDER_MMAP_SIZE_V7 : BINDER_MMAP_SIZE_V8;
void* const mapped_mem = mmap(nullptr, binder_map_size, PROT_READ, MAP_PRIVATE, binder_fd, 0);
Comment on lines +82 to +85
// Macro definitions for internal use
#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
#define BINDER_WRITE_READ_V7 _IOWR('b', 1, struct binder_write_read_v7)
#define BC_TRANSACTION_V7 _IOW('c', 0, struct binder_transaction_data_v7)
Comment on lines +150 to +155
bwr.write_size = write_size;
bwr.write_consumed = 0;
bwr.write_buffer = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(tx.write_payload.data()));
bwr.read_size = read_size;
bwr.read_consumed = 0;
bwr.read_buffer = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(tx.read_payload.data()));
Comment on lines +463 to +473
/* Probe with a 2-byte directed frame (GiveDevicePowerStatus) */
{
AutoLock lock_(mAidlMutex);
std::vector<uint8_t> probe;
probe.reserve(2);
probe.push_back(buf ? buf[0] : 0);
probe.push_back(0x8F); // GiveDevicePowerStatus

SendMessageStatus probeStatus = SendMessageStatus::BUSY;
android::binder::Status aidlStatus = mAidlController->sendMessage(probe, &probeStatus);
if (aidlStatus.isOk() && probeStatus == SendMessageStatus::ACK_STATE_0) {
Comment on lines +154 to +159
/**
* @brief Get the physical address of the device.
*
* Legacy: calls HdmiCecGetPhysicalAddress().
* AIDL: queries the physical address via binder.
*
Comment on lines +139 to +147
std::unique_ptr<IHDMICecHal> HDMICecHalFactory::Create()
{
CCEC_LOG(LOG_INFO, "HDMICecHalFactory::Create invoked\r\n");

try {
if (HalFactoryUtility::isAidlServiceAvailable(android::String16(IHdmiCec::serviceName().c_str()))) {
CCEC_LOG(LOG_INFO, "HDMICecHalFactory: Aidl Service is available — using HDMICecAidlHAL\r\n");
return std::make_unique<HDMICecAidlHAL>();
}
@anand-ky anand-ky changed the title VDevice : HDMI-CEC Middleware component RDKEMW-17873: HDMI-CEC Polaris HAL Migration Jun 24, 2026
@vinodtel

Copy link
Copy Markdown

I have read the CLA Document and I hereby sign the CLA.

@vinodtel
vinodtel changed the base branch from develop to support/AIDL June 26, 2026 16:39
Comment thread .github/workflows/L1-tests.yml Outdated

ln -sf ../../../mocks/hdmicec/hdmi_cec_driver.h stubs/ccec/drivers/hdmi_cec_driver.h

cat <<'EOF' > stubs/utils/String16.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headerfiles should not created from workflows. It should be maintained in stubs folder as original source file. So Can we remove header file creation here. Move it to stubs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Please review.

@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI review requested due to automatic review settings June 29, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.

Comment on lines +83 to +86
#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
#define BINDER_WRITE_READ_V7 _IOWR('b', 1, struct binder_write_read_v7)
#define BC_TRANSACTION_V7 _IOW('c', 0, struct binder_transaction_data_v7)

Comment on lines +106 to +110
const size_t tx_words = sizeof(txn) / sizeof(uint32_t);
tx.write_payload.reserve(1 + tx_words);
tx.write_payload.push_back(BC_TRANSACTION_V7);

tx.write_payload.resize(1 + tx_words);
Comment on lines +239 to +242
const size_t binder_map_size = (version.protocol_version == 7) ? BINDER_MMAP_SIZE_V7 : BINDER_MMAP_SIZE_V8;
void* const mapped_mem = mmap(nullptr, binder_map_size, PROT_READ, MAP_PRIVATE, binder_fd, 0);
if (mapped_mem == MAP_FAILED) {
CCEC_LOG(LOG_ERROR, "[-] Shared address space context instantiation failed\n");
Comment on lines +304 to +308
int HDMICecAidlHAL::getPhysicalAddress(int handle, unsigned int *physicalAddress)
{
if (physicalAddress != nullptr) {
*physicalAddress = 0;
}
Comment on lines +315 to +332
void HDMICecAidlHAL::dispatchRx(unsigned char *buf, int len)
{
if (mRxCb == nullptr) {
CCEC_LOG(LOG_DEBUG, "HDMICecAidlHAL::dispatchRx callback not registered\r\n");
return;
}

// Track initiator LA from inbound frames so 1-byte poll can be emulated
// locally on AIDL backends that reject 1-byte sendMessage payloads.
if (buf != nullptr && len >= 1) {
const uint8_t srcLA = static_cast<uint8_t>((buf[0] >> 4) & 0x0F);
if (srcLA <= 0x0E) {
AutoLock lock_(mAidlMutex);
mSeenLogicalAddresses.insert(srcLA);
}
}
mRxCb(0, mRxCbData, buf, len);
}
Comment on lines +344 to +353
int HDMICecAidlHAL::setRxCallback(int handle, HdmiCecRxCallback_t cbfunc, void *data)
{
(void)handle;

mRxCb = cbfunc;
mRxCbData = data;

CCEC_LOG(LOG_DEBUG, "HDMICecAidlHAL::setRxCallback invoked\r\n");
return 0;
}
Comment on lines +355 to +364
int HDMICecAidlHAL::setTxCallback(int handle, HdmiCecTxCallback_t cbfunc, void *data)
{
(void)handle;

mTxCb = cbfunc;
mTxCbData = data;

CCEC_LOG(LOG_DEBUG, "HDMICecAidlHAL::setTxCallback invoked\r\n");
return 0;
}
Comment on lines +463 to +486
/* Probe with a 2-byte directed frame (GiveDevicePowerStatus) */
{
AutoLock lock_(mAidlMutex);
std::vector<uint8_t> probe;
probe.reserve(2);
probe.push_back(buf ? buf[0] : 0);
probe.push_back(0x8F); // GiveDevicePowerStatus

SendMessageStatus probeStatus = SendMessageStatus::BUSY;
android::binder::Status aidlStatus = mAidlController->sendMessage(probe, &probeStatus);
if (aidlStatus.isOk() && probeStatus == SendMessageStatus::ACK_STATE_0) {
mSeenLogicalAddresses.insert(destination);
CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X ACKed by 2-byte probe. Emulating ack.\r\n",
destination);
return true;
}

CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X probe NACK/failed (aidlOk=%d status=%d).\r\n",
destination,
aidlStatus.isOk() ? 1 : 0,
static_cast<int>(probeStatus));
}
Comment on lines 76 to 87
- name: Generate stub headers
# Empty headers to mute errors
run: >
cd "$GITHUB_WORKSPACE/hdmicec"
&&
mkdir -p
stubs/rdk/iarmbus
stubs/ccec/drivers/iarmbus
stubs/binder
stubs/utils
stubs/linux/android
stubs/com/rdk/hal/hdmicec
&&
Comment on lines +139 to +154
std::unique_ptr<IHDMICecHal> HDMICecHalFactory::Create()
{
CCEC_LOG(LOG_INFO, "HDMICecHalFactory::Create invoked\r\n");

try {
if (HalFactoryUtility::isAidlServiceAvailable(android::String16(IHdmiCec::serviceName().c_str()))) {
CCEC_LOG(LOG_INFO, "HDMICecHalFactory: Aidl Service is available — using HDMICecAidlHAL\r\n");
return std::make_unique<HDMICecAidlHAL>();
}
} catch (...) {
CCEC_LOG(LOG_ERROR, "HDMICecHalFactory: Exception thrown while creating AIDL HAL,\r\n");
}

CCEC_LOG(LOG_INFO, "HDMICecHalFactory: Aidl Service is not available — using legacy HDMICecRdkVHAL\r\n");
return std::make_unique<HDMICecRdkVHAL>();
}
@IshvarKR
IshvarKR force-pushed the feature/factoryImpl branch from 248be82 to 5e1ed8e Compare June 29, 2026 09:46
Copilot AI review requested due to automatic review settings June 29, 2026 10:28
@IshvarKR
IshvarKR force-pushed the feature/factoryImpl branch from 5e1ed8e to 3dfa44b Compare June 29, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.


const size_t tx_words = sizeof(txn) / sizeof(uint32_t);
tx.write_payload.reserve(1 + tx_words);
tx.write_payload.push_back(BC_TRANSACTION_V7);
Comment on lines +304 to +313
int HDMICecAidlHAL::getPhysicalAddress(int handle, unsigned int *physicalAddress)
{
if (physicalAddress != nullptr) {
*physicalAddress = 0;
}

CCEC_LOG( LOG_DEBUG, "HDMICecAidlHAL::getPhysicalAddress completed\r\n");

return 0;
}
Comment on lines +139 to +147
std::unique_ptr<IHDMICecHal> HDMICecHalFactory::Create()
{
CCEC_LOG(LOG_INFO, "HDMICecHalFactory::Create invoked\r\n");

try {
if (HalFactoryUtility::isAidlServiceAvailable(android::String16(IHdmiCec::serviceName().c_str()))) {
CCEC_LOG(LOG_INFO, "HDMICecHalFactory: Aidl Service is available — using HDMICecAidlHAL\r\n");
return std::make_unique<HDMICecAidlHAL>();
}
@IshvarKR
IshvarKR force-pushed the feature/factoryImpl branch from 3dfa44b to 4a9145c Compare June 29, 2026 11:07
Copilot AI review requested due to automatic review settings June 29, 2026 11:16
@IshvarKR
IshvarKR force-pushed the feature/factoryImpl branch from 76022a7 to 3097ab2 Compare June 29, 2026 11:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.

Comment on lines +140 to +142
static bool execute_binder_ping(const int binder_fd, const int protocol_version) {
const BinderTransaction tx = (protocol_version == 7) ? prepare_v7_transaction() : prepare_v8_transaction();
uint32_t bytes_consumed = 0;
Comment on lines +239 to +245
const size_t binder_map_size = (version.protocol_version == 7) ? BINDER_MMAP_SIZE_V7 : BINDER_MMAP_SIZE_V8;
void* const mapped_mem = mmap(nullptr, binder_map_size, PROT_READ, MAP_PRIVATE, binder_fd, 0);
if (mapped_mem == MAP_FAILED) {
CCEC_LOG(LOG_ERROR, "[-] Shared address space context instantiation failed\n");
close(binder_fd);
return service_manager_alive;
}
Comment on lines +147 to +156
binder_write_read_v7 bwr{};
const size_t write_size = tx.write_payload.size() * sizeof(uint32_t);
const size_t read_size = tx.read_payload.size() * sizeof(uint32_t);
bwr.write_size = write_size;
bwr.write_consumed = 0;
bwr.write_buffer = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(tx.write_payload.data()));
bwr.read_size = read_size;
bwr.read_consumed = 0;
bwr.read_buffer = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(tx.read_payload.data()));

Comment on lines +304 to +313
int HDMICecAidlHAL::getPhysicalAddress(int handle, unsigned int *physicalAddress)
{
if (physicalAddress != nullptr) {
*physicalAddress = 0;
}

CCEC_LOG( LOG_DEBUG, "HDMICecAidlHAL::getPhysicalAddress completed\r\n");

return 0;
}
Comment on lines +441 to +503
bool HDMICecAidlHAL::emulateAckForPollFrames(const unsigned char *buf, int len)
{
if (len <= 1) {
/*
* Poll frame (header only): emulate ACK based on seen-LA cache
* and 2-byte probe. This keeps HdmiCecSource ping-based discovery
* working on AIDL backend.
*/
const uint8_t destination = (buf != NULL) ? (buf[0] & 0x0F) : 0xFF;

if (destination <= 0x0E) {
/* Check seen-LA cache first */
{
AutoLock lock_(mAidlMutex);
if (mSeenLogicalAddresses.count(destination) > 0) {
CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X present in seen-LA set. Emulating ack.\r\n",
destination);
return true;
}
}

/* Probe with a 2-byte directed frame (GiveDevicePowerStatus) */
{
AutoLock lock_(mAidlMutex);
std::vector<uint8_t> probe;
probe.reserve(2);
probe.push_back(buf ? buf[0] : 0);
probe.push_back(0x8F); // GiveDevicePowerStatus

SendMessageStatus probeStatus = SendMessageStatus::BUSY;
android::binder::Status aidlStatus = mAidlController->sendMessage(probe, &probeStatus);
if (aidlStatus.isOk() && probeStatus == SendMessageStatus::ACK_STATE_0) {
mSeenLogicalAddresses.insert(destination);
CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X ACKed by 2-byte probe. Emulating ack.\r\n",
destination);
return true;
}

CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X probe NACK/failed (aidlOk=%d status=%d).\r\n",
destination,
aidlStatus.isOk() ? 1 : 0,
static_cast<int>(probeStatus));
}
}

CCEC_LOG(LOG_DEBUG,
"HDMICecAidlHAL::emulateAckForPollFrames destination=0x%X not present. Returning no-ack.\r\n",
(buf != NULL) ? (buf[0] & 0x0F) : 0xFF);
throw CECNoAckException();
}

if (static_cast<size_t>(len) > kAidlMaxCecFrameSize) {
CCEC_LOG(LOG_EXP,
"HDMICecAidlHAL::emulateAckForPollFrames blocking unsupported CEC frame length=%zu on AIDL backend (valid range: 2..16).\r\n",
static_cast<size_t>(len));
throw IOException();
}

return false;
}
Comment on lines +21 to +22
#include <cstdint>
#include <cstdlib>
Comment on lines +58 to +64
CCEC_LOG(LOG_INFO, "isAidlServiceAvailable invoked\r\n");

if (mBackendType == BackendType::AIDL) {
return true;
} else if (mBackendType == BackendType::LEGACY) {
return false;
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.

Comment on lines +43 to +51
#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
#define BC_TRANSACTION 0x0
#define TF_ACCEPT_FDS 0x10
#define BR_REPLY 0x1
#define BR_DEAD_REPLY 0x2
#define BR_FAILED_REPLY 0x3
#define BR_TRANSACTION_COMPLETE 0x4
#define BR_NOOP 0x5
#define BR_OK 0x6
Comment thread ccec/src/Makefile
Comment on lines +38 to +42
# Calculate AIDL include path relative to workspace
AIDL_GEN_DIR := $(shell cd ../../.. && pwd)/aidl/rdk-halif-aidl/gen/hdmicec/current
AIDL_H_DIR := $(AIDL_GEN_DIR)/h
BINDER_IDL_DIR := $(shell cd ../../.. && pwd)/aidl/rdk-halif-aidl/build-tools/linux_binder_idl
BINDER_INCLUDE := $(BINDER_IDL_DIR)/android/native/libs/binder/include
Comment on lines +80 to +83
// Return the standard logical-address candidates for a given device type.
// Used only as a fallback when AIDL reports no allocated addresses yet.
std::vector<int32_t> preferredLogicalAddressesForDeviceType(int devType)
{
Comment on lines +304 to +313
int HDMICecAidlHAL::getPhysicalAddress(int handle, unsigned int *physicalAddress)
{
if (physicalAddress != nullptr) {
*physicalAddress = 0;
}

CCEC_LOG( LOG_DEBUG, "HDMICecAidlHAL::getPhysicalAddress completed\r\n");

return 0;
}
Comment on lines +60 to +63
private:
const size_t kAidlMinCecFrameSize = 2;
const size_t kAidlMaxCecFrameSize = 16;
android::sp<com::rdk::hal::hdmicec::IHdmiCec> getAidlService();
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants